<?php

require_once '../config/config.php';

class db {

    public $connection;

    public function connect() {
         $this->connection = mysql_connect(DB_HOST . ":" . DB_PORT, DB_USER, DB_PASS) or die(mysql_error());
        mysql_select_db(DB_NAME, $this->connection);
        return $this->connection;
    }
    

    public function query($query) {
        $datas = array();
        mysql_query("SET NAMES utf8", $this->connection);
        $query = mysql_query($query, $this->connection);
        while ($row = mysql_fetch_assoc($query))
            $datas[] = $row;
        return $datas;
    }
    
      public function keywork(){      
            $this->connect();
            $query = "SELECT * FROM keywords WHERE LENGTH(name) > 10";
            $keywords = $this->query($query);
            return $keywords;
    }
    
    public function works() {
        $this->connect();
        $query = "SELECT * FROM works LIMIT 0,10";
        $work = $this->query($query);
        return $work;
    }

}

?>